﻿#region Usings

using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using DbConvertor.Dao.Entities;

#endregion

namespace DbConvertor.Dao
{
    public class RailnetContext : DbContext
    {
        public DbSet<Ru> Rus { get; set; }

        public DbSet<Station> Stations { get; set; }

        public DbSet<Relation> Relations { get; set; }

        public DbSet<RelationDescription> RelationDescriptions { get; set; }

        public DbSet<RelationRu> RelationRus { get; set; }

        public DbSet<Distance> Distances { get; set; }

        public DbSet<PriceDistance> PriceDistances { get; set; }

        public DbSet<PriceSerial> PriceSerials { get; set; }

        public DbSet<PriceDomestic> PriceDomestics { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<PriceDistance>().Property(price => price.Price).HasPrecision(18, 2);
            modelBuilder.Entity<PriceSerial>().Property(price => price.Price).HasPrecision(18, 2);
            modelBuilder.Entity<PriceDomestic>().Property(price => price.Price).HasPrecision(18, 2);
            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();


            base.OnModelCreating(modelBuilder);
        }
    }
}